<template lang="pug">
  el-form(:model="tiwen" label-position="right" label-width="100px")
    el-form-item(label="添加体温记录")
    el-form-item(label="时间")
      el-date-picker(v-model="tiwen.createtime" type="datetime"  format="yyyy-MM-dd HH:mm:ss"
      value-format="yyyy-MM-dd HH:mm:ss" placeholder="请选择时间")
    el-form-item(label="体温")
      el-input(v-model='tiwen.tp' placeholder="请输入体温")
    el-form-item(label="地点")
      el-input(v-model='tiwen.address' placeholder="请输入地点")
    el-form-item
      el-button(type="primary" @click="submitGuiji") 提交
</template>
<script>
export default {
  data() {
    return {
      tiwen: {
        createtime: '',
        tp: '',
        address: ''
      }
    }
  },
  mounted() {
    if (this.$route.query.id) {
      this.tiwen = this.$store.state.guijiItem
    }
  },
  computed: {
    userInfo() {
      return this.$store.state.userInfo
    }
  },
  methods: {
    //添加温度 
    submitGuiji() {
      if (this.$route.query.id) {
        this.editSubmitGuiji()
      } else {
        this.$http('health/tprecord/saveOrUpdate', {
          ...this.tiwen,
          personid: this.$route.query.personId,
          type: this.$route.query.type * 1,
          id: 0,
          createdate: this.tiwen.createtime,
          name: this.userInfo.name
        }, 'POST').then(res => {
          this.$notify.success(res.message)
          this.$router.push(
            {
              path: '/monitorDetails',
              query: {
                personId: this.$route.query.personId,
                type: this.$route.query.type
              }
            }
          )
        })
      }
    },
    //修改轨迹
    editSubmitGuiji() {
      this.$http('health/tprecord/saveOrUpdate', {
        createtime: this.tiwen.createtime,
        tp: this.tiwen.tp,
        address: this.tiwen.address,
        personid: this.$route.query.personId,
        type: this.$route.query.type,
        id: this.$route.query.id,
        createdate: this.tiwen.createtime
      }, 'POST').then(res => {
        this.$notify.success(res.message)
        this.$router.push(
          {
            path: '/monitorDetails',
            query: {
              personId: this.$route.query.personId,
              type: this.$route.query.type
            }
          }
        )
      })
    },
  }
}
</script>

<style scoped>
.el-form {
	color: #fff;
	width: 60%;
	/* display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	box-sizing: border-box;
	background: #fff; */
}
>>> .el-form-item__label {
	color: #fff;
}
</style>

